package com.atguigu.tingshu.user.client;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.client.impl.UserDegradeFeignClient;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户模块远程调用API接口
 * </p>
 *
 * @author atguigu
 */
@FeignClient(value = "service-user",path = "api/user", fallback = UserDegradeFeignClient.class)
public interface UserFeignClient {

    @GetMapping("/userInfo/getUserInfoVo/{userId}")
    public Result<UserInfoVo> getUserInfoVo(@PathVariable Long userId);

    /**
     * 获取每一页声音列表（提交声音ID集合）对应购买状态
     *
     * @param
     * @param albumId                      专辑ID
     * @param needCheckPayStateTrackIdList 需要检查购买状态的声音ID集合
     * @return {声音ID:1(已购),声音ID:0(未购)}
     */

    @PostMapping("/userInfo/userIsPaidTrack/{albumId}")
    public Result<Map<Long, Integer>> userIsPaidTrack(
            @PathVariable("albumId") Long albumId,
            @RequestBody List<Long> needCheckPayStateTrackIdList
    );





    /**
     * 查询指定VIP服务配置
     * @param id
     * @return
     */
    @GetMapping("/vipServiceConfig/getVipServiceConfig/{id}")
    public Result<VipServiceConfig> getVipServiceConfig(@PathVariable Long id);


    /**
     * 判断当前用户是否购买过指定专辑
     *
     * @param albumId
     * @return
     */
    @GetMapping("/userInfo/isPaidAlbum/{albumId}")
    public Result<Boolean> isPaidAlbum(@PathVariable Long albumId);


    /**
     * 查询当前用户某个专辑下已购声音ID列表
     * @param albumId
     * @return
     */
    @GetMapping("/userInfo/findUserPaidTrackList/{albumId}")
    public Result<List<Long>> findUserPaidTrackList(@PathVariable Long albumId);

    /**
     * 用户支付成功后，权益方法，虚拟物品（VIP会员、专辑、声音）发货
     * 如果支付方式是微信，微信支付会异步回调，没有token造成接口无法调用，故不加@GuiGuLogin注解
     * @param userPaidRecordVo
     * @return
     */
    @PostMapping("/userInfo/savePaidRecord")
    public Result savePaidRecord(@RequestBody UserPaidRecordVo userPaidRecordVo);


    /**
     * 更新VIP状态：处理过期会员
     * @return
     */
    @GetMapping("/updateVipExpireStatus")
    public Result updateVipExpireStatus();
}
